import java.util.Arrays;

public class text2 {
    public static void fun2(int[] array){
        int left=0;
        int right= array.length-1;
        while(left<right){
            while(array[left]%2!=0){
                left++;
            }
            while((array[right]%2)==0){
                right--;
            }
            if(left<right) {
                int tmp = array[left];
                array[left] = array[right];
                array[right] = tmp;
                left++;right--;
            }
        }
    }

    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6};
        fun2(array);
        System.out.println(Arrays.toString(array));
    }
}
